/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.zcm.modules.nbg.web.rest;

import com.zcm.common.utils.StringUtils;
import com.zcm.common.web.BaseController;
import com.zcm.modules.nbg.entity.*;
import com.zcm.modules.nbg.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 看盘数据Controller
 * @author www
 * @version 2018-04-17
 */
@Controller
@RequestMapping(value = "/rest")
public class NbgRestController extends BaseController {

    @Autowired
    private NbgBaseDataService nbgBaseDataService;
    @Autowired
    private NbgBeixuanService nbgBeixuanService;
    @Autowired
    private NbgFengkoService nbgFengkoService;
    @Autowired
    private NbgFengkoDetailService nbgFengkoDetailService;
    @Autowired
    private NbgJuechechiService nbgJuechechiService;
    @Autowired
    private NbgLtyaoguService nbgLtyaoguService;
    @Autowired
    private NbgZujichiService nbgZujichiService;

    @RequestMapping(value = "baseData")
	@ResponseBody
	public Map baseData(@RequestParam(value = "day",required = false,defaultValue = "")String day,
                        @RequestParam(value = "title",required = false,defaultValue = "")String title) {
        NbgBaseData nbgBaseData= new NbgBaseData();
        if(StringUtils.isEmpty(day)){
            day = String.format("%tF",new Date());
        }

        if(StringUtils.isEmpty(title)){
            nbgBaseData.setTitle(title);
        }
        nbgBaseData.setRq(day);
        List  list = nbgBaseDataService.findList(nbgBaseData);
        Map<String,Object> result = new HashMap<String, Object>();
        result.put("ret",true);
        result.put("count",list.size());
        result.put("data",list);
        return result;
	}
    @RequestMapping(value = "beixuan")
    @ResponseBody
    public Map beixuan(@RequestParam(value = "day",required = false,defaultValue = "")String day) {
        if(StringUtils.isEmpty(day)){
            day = String.format("%tF",new Date());
        }
        NbgBeixuan nbgBaseData= new NbgBeixuan();
        nbgBaseData.setRq(day);
        List  list = nbgBeixuanService.findList(nbgBaseData);
        Map<String,Object> result = new HashMap<String, Object>();
        result.put("ret",true);
        result.put("count",list.size());
        result.put("data",list);
        return result;
    }


    @RequestMapping(value = "fengko")
    @ResponseBody
    public Map fengko(@RequestParam(value = "day",required = false,defaultValue = "")String day) {
        if(StringUtils.isEmpty(day)){
            day = String.format("%tF",new Date());
        }
        NbgFengko nbgFengko= new NbgFengko();
        nbgFengko.setRq(day);
        List  list = nbgFengkoService.findList(nbgFengko);
        Map<String,Object> result = new HashMap<String, Object>();
        result.put("ret",true);
        result.put("count",list.size());
        result.put("data",list);
        return result;
    }


    @RequestMapping(value = "fengkoDetail")
    @ResponseBody
    public Map fengkoDetail(@RequestParam(value = "fengkoId",required = true,defaultValue = "")String fengkoId) {
        NbgFengkoDetail nbgFengkoDetail= new NbgFengkoDetail();
        nbgFengkoDetail.setFengkoId(fengkoId);
        List  list = nbgFengkoDetailService.findList(nbgFengkoDetail);
        Map<String,Object> result = new HashMap<String, Object>();
        result.put("ret",true);
        result.put("count",list.size());
        result.put("data",list);
        return result;
    }



    @RequestMapping(value = "juechechi")
    @ResponseBody
    public Map juechechi(@RequestParam(value = "day",required = false,defaultValue = "")String day) {
        if(StringUtils.isEmpty(day)){
            day = String.format("%tF",new Date());
        }
        NbgJuechechi nbgJuechechi= new NbgJuechechi();
        nbgJuechechi.setRq(day);
        List  list = nbgJuechechiService.findList(nbgJuechechi);
        Map<String,Object> result = new HashMap<String, Object>();
        result.put("ret",true);
        result.put("count",list.size());
        result.put("data",list);
        return result;
    }



    @RequestMapping(value = "ltyaogu")
    @ResponseBody
    public Map ltyaogu(@RequestParam(value = "day",required = false,defaultValue = "")String day) {
        if(StringUtils.isEmpty(day)){
            day = String.format("%tF",new Date());
        }
        NbgLtyaogu nbgLtyaogu= new NbgLtyaogu();
        nbgLtyaogu.setRq(day);
        List  list = nbgLtyaoguService.findList(nbgLtyaogu);
        Map<String,Object> result = new HashMap<String, Object>();
        result.put("ret",true);
        result.put("count",list.size());
        result.put("data",list);
        return result;
    }


    @RequestMapping(value = "zujichi")
    @ResponseBody
    public Map zujichi(@RequestParam(value = "day",required = false,defaultValue = "")String day) {
        if(StringUtils.isEmpty(day)){
            day = String.format("%tF",new Date());
        }
        NbgZujichi nbgZujichi= new NbgZujichi();
        nbgZujichi.setRq(day);
        List  list = nbgZujichiService.findList(nbgZujichi);
        Map<String,Object> result = new HashMap<String, Object>();
        result.put("ret",true);
        result.put("count",list.size());
        result.put("data",list);
        return result;
    }
}